package com.xcity.game.item.effect;

import java.text.MessageFormat;

import com.xcity.db.entity.Player;
import com.xcity.game.common.Cause;
import com.xcity.game.common.MessageConst;
import com.xcity.game.item.GameItem;
import com.xcity.game.item.ItemEffect;
import com.xcity.game.item.ItemException;
import com.xcity.game.item.listener.BagListener;
import com.xcity.pomelo.push.msg.TipPush;

/**
 * 增加体力
 * @author YangLi
 *
 */
public class AddStrengthEffect implements ItemEffect {

	@Override
	public boolean effect(Player player, GameItem item, int count, BagListener listener) throws ItemException {
		int str = item.getTemplate().getParameter(0) * count;
		if (str <= 0) {
			return false;
		}
		if (player.addStrength2(str, Cause.USE_ITEM)) {
			player.send(new TipPush(MessageFormat.format(MessageConst.STRENGTH_ADDED, str)));
			return true;
		}
		throw new ItemException(MessageConst.STRENGTH_FULL);
	}

}
